package com.shrct.businessprocess.customerservice.impl;

import com.shrct.businessprocess.customerservice.RCRoutineService;
import com.shrct.businessprocess.customerservice.RCRoutineServiceCriteria;
import edu.fudan.mylang.pf.query.HQLBasedPagedQueryCriteria;
import java.util.Date;
import org.hibernate.Query;

public class RCRoutineServiceCriteriaImpl extends HQLBasedPagedQueryCriteria<RCRoutineService> implements RCRoutineServiceCriteria {
  private Date routineStartDateFrom;
  
  public Date getRoutineStartDateFrom() {
    return this.routineStartDateFrom;
  }
  
  public RCRoutineServiceCriteria setRoutineStartDateFrom(final Date routineStartDateFrom) {
    this.routineStartDateFrom = routineStartDateFrom;
    return this;			
    
  }
  
  private Date routineStartDateTo;
  
  public Date getRoutineStartDateTo() {
    return this.routineStartDateTo;
  }
  
  public RCRoutineServiceCriteria setRoutineStartDateTo(final Date routineStartDateTo) {
    this.routineStartDateTo = routineStartDateTo;
    return this;			
    
  }
  
  protected String buildHQLFrom() {
    return " from com.shrct.businessprocess.customerservice.impl.RCRoutineServiceImpl this ";
  }
  
  protected String buildHQLBody() {
    String hql = "where 1 = 1 ";
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getRoutineStartDateFrom()) ){
    	hql += " and ((this.routineStartDate) >= (:routineStartDateFrom))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getRoutineStartDateTo()) ){
    	hql += " and ((this.routineStartDate) <= (:routineStartDateTo))" ;
    }
    return hql;
    
  }
  
  public void initOrderBys() {
    addOrder("this.projectInfo.projectId",edu.fudan.mylang.pf.query.OrderItem.DESC);
  }
  
  protected void fillParameter(final Query query) {
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getRoutineStartDateFrom())){
    	query.setParameter("routineStartDateFrom",getRoutineStartDateFrom()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getRoutineStartDateTo())){
    	query.setParameter("routineStartDateTo",getRoutineStartDateTo()) ;
    }			
    
  }
  
  protected Boolean isDistinct() {
    return false;
  }
  
  public RCRoutineServiceCriteriaImpl() {
    initOrderBys();
  }
}
